package cn.io.bio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @author summit
 * @since 2022/5/11 10:36
 */
public class TcpClient {

	public static void main(String[] args) throws IOException {
		Socket socket = new Socket("127.0.0.1", 9000);
		OutputStream os = socket.getOutputStream();
		System.out.println("请输:");
		Scanner scanner = new Scanner(System.in);
		String msg = scanner.nextLine();
		os.write(msg.getBytes());

		InputStream is = socket.getInputStream();
		byte[] b = new byte[10];
		is.read(b);

		System.out.println("返回信息:" + new String(b));
		socket.close();
	}
}
